import React, { CSSProperties } from 'react'

interface PropsType {
  text: string
  isCenter?: boolean
}

const QuestionParagraph: React.FC<PropsType> = ({ text, isCenter }) => {
  const style: CSSProperties = {}
  if (isCenter) style.textAlign = 'center'

  // 换行
  const textList = text.split('\n')
  return (
    <p style={style}>
      {textList.map((t, index) => {
        return (
          <span key={index}>
            {index > 0 && <br />}
            {t}
          </span>
        )
      })}
    </p>
  )
}

export default QuestionParagraph
